<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>get</title>
</head>

<body>
  黄鹏
  <form onsubmit="upload(event)">
    <input type="text" id="username" />
    <input type="file" id="file" />
    <input type="submit" />
  </form>
  <script>
    function upload(event) {
      event.preventDefault();
      let username = document.getElementById('username').value;
      let file = document.getElementById('file').files[0];
      let xhr = new XMLHttpRequest();
      xhr.open("POST", "http://localhost:8083/upload");
      var formData = new FormData();
      formData.append("username", username);
      formData.append("file", file);
      xhr.responseType = "text";
      xhr.onload = () => {
        console.log(xhr.response);
      };
      xhr.send(formData);
    }
  </script>
</body>

</html>